home *** CD-ROM | disk | FTP | other *** search
- /* $Id: EVDLLRT.H 1.12 1995/10/05 20:02:11 JOHN Exp $ */
-
- #ifndef __EVDLLRT__
- #define __EVDLLRT__
-
- #ifndef _WIN31
- #define __cdecl
- #endif
-
- #ifdef _WIN16
- typedef int jmp_buf[9];
- #define setjmp RDSetJump
- #define longjmp RDLongJump
- #endif
-
- #ifdef _WIN32
- typedef int jmp_buf[16];
- #ifdef __cplusplus
- extern "C" {
- #endif
- int __cdecl RDSetJump(jmp_buf);
- void __cdecl RDLongJump(jmp_buf, int);
- #ifdef __cplusplus
- }
- #endif
- #define setjmp RDSetJump
- #define longjmp RDLongJump
- #endif
-
- #ifdef _MAC
- #ifdef qPowerPC
- typedef long jmp_buf[64];
- extern "C" int PPCSetJmp(jmp_buf);
- extern "C" void PPCLongJmp(jmp_buf, int);
- #define setjmp PPCSetJmp
- #define longjmp PPCLongJmp
- #else
- #include <SetJmp.h>
- #endif
- #endif
-
-
- #ifndef qRFrame
- typedef struct {
- short fResFile;
- Handle fTopMapHandle;
- } RDDRMap;
- #else
- typedef long RDDRMap;
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- void FailNIL(void* apointer);
- void FailOSErr(short err);
-
- extern void RDDLLMain(void);
-
- #ifdef qPowerPC
- void RDDLLInit(void);
- #endif
- short __cdecl RDDLLExport(void (*f)(void), char* name, long appvars);
-
- void RDDLLSetupResource(RDDRMap* oldMap);
- void RDDLLRestoreResource(RDDRMap* oldMap);
-
- long RDDLLSetupA5(void);
- void RDDLLRestoreA5(long oldA5);
-
- long __cdecl RDDLLTickCount(void);
- long __cdecl RDDLLStackSpace(void);
-
- #ifdef __cplusplus
- }
- #endif
-
- #if defined(_WIN31)
- #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))f, #f, 0);
- #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))f, n, 0);
- #elif defined(__MWERKS__)
- #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))f, #f, *(long*)0x316);
- #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))f, n, *(long*)0x316);
- #else
- #define RDEXPORTPROC(f) RDDLLExport((void(*)(void))&f, #f, *(long*)0x316);
- #define RDEXPORTMEMBER(f,n) RDDLLExport((void(*)(void))&f, n, *(long*)0x316);
- #endif
-
- #ifdef __cplusplus
-
- #define VOLATILE(a) ((void)&a)
-
- class FailInfo {
- public:
- jmp_buf savedState;
- short error;
- long message;
- FailInfo* nextInfo;
- public:
- FailInfo();
- inline void ReSignal();
- inline void Success();
- inline void Reset();
- };
- typedef FailInfo* FailInfoPtr;
-
- extern "C" {
- void __cdecl Failure(short error, long message);
- FailInfoPtr* __cdecl GetGTopHandler(void);
- }
-
- //----------------------------------------------------------------------------------------
- // FailInfo inline method definitions
- //----------------------------------------------------------------------------------------
-
- #ifdef qPowerPC
- extern "C" int PPCSetJmp(jmp_buf env);
- #define TRY(f) \
- f.nextInfo = *GetGTopHandler(), \
- *GetGTopHandler() = &f, \
- (PPCSetJmp(f.savedState)==0)
- #else
- #define TRY(f) \
- f.nextInfo = *GetGTopHandler(), \
- *GetGTopHandler() = &f, \
- (setjmp(f.savedState)==0)
- #endif
-
- inline void FailInfo::Reset() {
- error = 0;
- message = 0;
- nextInfo = 0;
- }
-
- #if 0
- inline Boolean FailInfo::Try() {
- return ::Try(*this);
- }
- #endif
-
- inline FailInfo::FailInfo() {
- }
-
- inline void FailInfo::ReSignal() {
- ::Failure(error, message);
- }
-
- inline void FailInfo::Success() {
- *GetGTopHandler() = nextInfo;
- }
-
- #endif
-
- #endif
-